/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package podologia.beansDB;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 *
 * @author Hernan
 */
@Entity
@Table(name = "detallepago")
@NamedQueries({@NamedQuery(name = "Detallepago.findByIdDetalle", query = "SELECT d FROM Detallepago d WHERE d.idDetalle = :idDetalle"), @NamedQuery(name = "Detallepago.findByCostoUnitario", query = "SELECT d FROM Detallepago d WHERE d.costoUnitario = :costoUnitario"), @NamedQuery(name = "Detallepago.findByCantidad", query = "SELECT d FROM Detallepago d WHERE d.cantidad = :cantidad")})
public class Detallepago implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy=GenerationType.SEQUENCE)
    @Column(name = "idDetalle", nullable = false)
    private Integer idDetalle;
    @Column(name = "costoUnitario")
    private Float costoUnitario;
    @Column(name = "cantidad")
    private Integer cantidad;
    @JoinColumn(name = "nrofactura", referencedColumnName = "nroFactura")
    @ManyToOne
    private Pago nrofactura;
    @JoinColumn(name = "idAtencion", referencedColumnName = "idAtencion")
    @ManyToOne
    private Atencion idAtencion;

    public Detallepago() {
    }

    public Detallepago(Integer idDetalle) {
        this.idDetalle = idDetalle;
    }

    public Integer getIdDetalle() {
        return idDetalle;
    }

    public void setCantidad(Float montoAtencion) {
        throw new UnsupportedOperationException("Not yet implemented");
    }

    public void setIdDetalle(Integer idDetalle) {
        Integer oldIdDetalle = this.idDetalle;
        this.idDetalle = idDetalle;
        changeSupport.firePropertyChange("idDetalle", oldIdDetalle, idDetalle);
    }

    public Float getCostoUnitario() {
        return costoUnitario;
    }

    public void setCostoUnitario(Float costoUnitario) {
        Float oldCostoUnitario = this.costoUnitario;
        this.costoUnitario = costoUnitario;
        changeSupport.firePropertyChange("costoUnitario", oldCostoUnitario, costoUnitario);
    }

    public Integer getCantidad() {
        return cantidad;
    }

    public void setCantidad(Integer cantidad) {
        Integer oldCantidad = this.cantidad;
        this.cantidad = cantidad;
        changeSupport.firePropertyChange("cantidad", oldCantidad, cantidad);
    }

    public Pago getNrofactura() {
        return nrofactura;
    }

    public void setNrofactura(Pago nrofactura) {
        Pago oldNrofactura = this.nrofactura;
        this.nrofactura = nrofactura;
        changeSupport.firePropertyChange("nrofactura", oldNrofactura, nrofactura);
    }

    public Atencion getIdAtencion() {
        return idAtencion;
    }

    public void setIdAtencion(Atencion idAtencion) {
        Atencion oldIdAtencion = this.idAtencion;
        this.idAtencion = idAtencion;
        changeSupport.firePropertyChange("idAtencion", oldIdAtencion, idAtencion);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idDetalle != null ? idDetalle.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Detallepago)) {
            return false;
        }
        Detallepago other = (Detallepago) object;
        if ((this.idDetalle == null && other.idDetalle != null) || (this.idDetalle != null && !this.idDetalle.equals(other.idDetalle))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "podologia.beansDB.Detallepago[idDetalle=" + idDetalle + "]";
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }

}
